﻿@model IEnumerable<TCC.CMFlow.Models.GrupoAprovacao>

@{
    ViewBag.Title = "Ordem de Aprovação dos Grupos";

    var _categoriaWorkflowID = Convert.ToInt32(ViewData["CategoriaWorkflowID"]);
}

<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
    <h4 class="modal-title" id="myModalLabel">@ViewBag.Title</h4>
</div>

<div class="modal-body">
    <ul id="sortable" class="list-group">
        @foreach (var item in Model)
        {
            <li class="list-group-item" id="@Html.AttributeEncode(item.ID)">@Html.AttributeEncode(item.Nome)</li>
        }
    </ul>
</div>

<div class="modal-footer">
    <button class="btn" data-dismiss="modal">Cancelar</button>
    <input type="submit" id="submit-ordem" value="Cadastrar" class="btn btn-primary" />
</div>

<script type="text/javascript">
    $(function () {
        $("#sortable").sortable();
    });

    $(function () {
        $("#submit-ordem").button();

        $("#submit-ordem").click(function () {
            $.ajax({
                url: '@Url.Action("OrdenarGrupo", "CategoriaWorkflow")', //'/TCC.CMFlow/CategoriaWorkflow/OrdenarGrupo/',
                type: 'POST',
                dataType: "json",
                data: { id: '@ViewContext.RouteData.Values["id"]', items: $("#sortable").sortable('toArray') },
                traditional: true
            });
        });

    });
</script>